#!/bin/bash
LOGPATH=$1
filelst=`ls -1  $LOGPATH`
total_error_number=0
total_warn_number=0
for filename in $filelst; do
    error_number=0
    warn_number=0
    if [ -f $filename ]; then
        error_number=`grep -c ERROR $filename`
        warn_number=`grep -c WARN $filename`
        total_error_number=$[ total_error_number + error_number ]
        total_warn_number=$[ total_warn_number + warn_number ]
    fi
done
echo "{ \"error\":$total_error_number, \"warn\":$total_warn_number }"